home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / src / xffontBox.tcl < prev    next >
Encoding:
Text File  |  1993-11-20  |  21.7 KB  |  679 lines

  1. # XFNoParsing
  2. # Program: template
  3. # Description: font selection
  4. #
  5. # $Header: xffontBox.tcl[2.4] Wed Mar 10 12:05:51 1993 garfield@garfield frozen $
  6.  
  7. global xfFontBox
  8. set xfFontBox(activeBackground) ""
  9. set xfFontBox(activeForeground) ""
  10. set xfFontBox(background) ""
  11. set xfFontBox(font) ""
  12. set xfFontBox(font-demo) "This text shows the results :-)"
  13. set xfFontBox(kanjifont-demo) "ñ│ñ∞ñ¼ñ╜ñ╬Ñ╒Ñ⌐Ñ≤Ñ╚ñ╟ñ╣íú"
  14. set xfFontBox(foreground) ""
  15. set xfFontBox(scrollActiveForeground) ""
  16. set xfFontBox(scrollBackground) ""
  17. set xfFontBox(scrollForeground) ""
  18. set xfFontBox(fontName) ""
  19. set xfFontBox(fontFamily) *
  20. set xfFontBox(fontPixels) *
  21. set xfFontBox(fontSlant) *
  22. set xfFontBox(fontSWidth) *
  23. set xfFontBox(fontWeight) *
  24. set xfFontBox(resource) "font"
  25.  
  26. proc XFFontBox {{xfFontBoxFileFont "/usr/local/lib/xf/lib/Fonts"} {xfFontBoxResource "Font"} {xfFontBoxEntryW ""} {xfFontBoxTargetW ""}} {# xf ignore me 5
  27. ##########
  28. # Procedure: XFFontBox
  29. # Description: select a font
  30. # Arguments: {xfFontBoxFileFont} - the font file with all fontnames
  31. #            {xfFontBoxResource} - the resource to modify
  32. #            {xfFontBoxEntryW} - the widget name for the resulting font name
  33. #            {xfFontBoxTargetW} - the widget we configure
  34. # Returns: fontname, or nothing
  35. # Sideeffects: none
  36. ##########
  37. # global xfFontBox(activeBackground) - active background color
  38. # global xfFontBox(activeForeground) - active foreground color
  39. # global xfFontBox(background) - background color
  40. # global xfFontBox(font) - text font
  41. # global xfFontBox(foreground) - foreground color
  42. # global xfFontBox(scrollActiveForeground) - scrollbar active background color
  43. # global xfFontBox(scrollBackground) - scrollbar background color
  44. # global xfFontBox(scrollForeground) - scrollbar foreground color
  45. # global xfFontBox(scrollSide) - side where scrollbar is located
  46.  
  47.   global xfFontBox
  48.   global tkVersion
  49.  
  50.   set xfFontBox(fontName) ""
  51.   set xfFontBox(fontFamily) *
  52.   set xfFontBox(fontPixels) *
  53.   set xfFontBox(fontSlant) *
  54.   set xfFontBox(fontSWidth) *
  55.   set xfFontBox(fontWeight) *
  56.  
  57.   set tmpButtonOpt ""
  58.   set tmpFrameOpt ""
  59.   set tmpMessageOpt ""
  60.   set tmpScrollOpt ""
  61.   if {"$xfFontBox(activeBackground)" != ""} {
  62.     append tmpButtonOpt "-activebackground \"$xfFontBox(activeBackground)\" "
  63.   }
  64.   if {"$xfFontBox(activeForeground)" != ""} {
  65.     append tmpButtonOpt "-activeforeground \"$xfFontBox(activeForeground)\" "
  66.   }
  67.   if {"$xfFontBox(background)" != ""} {
  68.     append tmpButtonOpt "-background \"$xfFontBox(background)\" "
  69.     append tmpFrameOpt "-background \"$xfFontBox(background)\" "
  70.     append tmpMessageOpt "-background \"$xfFontBox(background)\" "
  71.   }
  72.   if {"$xfFontBox(font)" != ""} {
  73.     append tmpButtonOpt "-$xfFontBox(resource) \"$xfFontBox(font)\" "
  74.     append tmpMessageOpt "-$xfFontBox(resource) \"$xfFontBox(font)\" "
  75.   }
  76.   if {"$xfFontBox(foreground)" != ""} {
  77.     append tmpButtonOpt "-foreground \"$xfFontBox(foreground)\" "
  78.     append tmpMessageOpt "-foreground \"$xfFontBox(foreground)\" "
  79.   }
  80.   if {"$xfFontBox(scrollActiveForeground)" != ""} {
  81.     append tmpScrollOpt "-activeforeground \"$xfFontBox(scrollActiveForeground)\" "
  82.   }
  83.   if {"$xfFontBox(scrollBackground)" != ""} {
  84.     append tmpScrollOpt "-background \"$xfFontBox(scrollBackground)\" "
  85.   }
  86.   if {"$xfFontBox(scrollForeground)" != ""} {
  87.     append tmpScrollOpt "-foreground \"$xfFontBox(scrollForeground)\" "
  88.   }
  89.  
  90.   set xfFontBoxTmpFileFont $xfFontBoxFileFont 
  91.   # get font file name
  92.   if {!([file exists $xfFontBoxFileFont] &&
  93.         [file readable $xfFontBoxFileFont])} {
  94.     set xfFontBoxFileFont ""
  95.   }
  96.   if {"$xfFontBoxFileFont" == ""} {
  97.     global env
  98.     if {[info exists env(XF_FONT_FILE)]} {
  99.       if {[file exists $env(XF_FONT_FILE)] &&
  100.           [file readable $env(XF_FONT_FILE)]} {
  101.         set xfFontBoxFileFont $env(XF_FONT_FILE)
  102.       }
  103.     }
  104.   }
  105.   if {"$xfFontBoxResource" == ""} {
  106.     set xfFontBoxResource "Font"
  107.   }
  108.   set xfFontBox(resource) [string tolower $xfFontBoxResource]
  109.  
  110.   # save the the current widget color
  111.   if {"$xfFontBoxTargetW" != ""} {
  112.     if {[catch "$xfFontBoxTargetW config -$xfFontBox(resource)" result]} {
  113.       set xfFontBoxSavedFont ""
  114.     } {
  115.       set xfFontBoxSavedFont [lindex $result 4]
  116.     }
  117.   } {
  118.     set xfFontBoxSavedFont ""
  119.   }
  120.  
  121.   # look if there is already a font window
  122.   if {"[info commands .xfFontBox]" == ""} {
  123.     # build widget structure
  124.  
  125.     XFTmpltToplevel .xfFontBox 600x300 {XF font select}
  126.  
  127.     set xfFontBox(oldWidget) $xfFontBoxEntryW
  128.  
  129.     frame .xfFontBox.frame1 \
  130.       -borderwidth 0 \
  131.       -relief raised
  132.     catch ".xfFontBox.frame1 config $tmpFrameOpt"
  133.  
  134.     frame .xfFontBox.frame2 \
  135.       -borderwidth 2 \
  136.       -relief raised
  137.     catch ".xfFontBox.frame2 config $tmpFrameOpt"
  138.  
  139.     button .xfFontBox.frame1.ok \
  140.       -text "OK"
  141.     catch ".xfFontBox.frame1.ok config $tmpButtonOpt"
  142.  
  143.     button .xfFontBox.frame1.rescan \
  144.       -text "Rescan fonts" \
  145.       -command "
  146.         if {\"$xfFontBoxTmpFileFont\" != \"\"} {
  147.           catch \"exec xlsfonts > $xfFontBoxTmpFileFont\"
  148.           if {\[.xfFontBox.fonts.fonts size\] > 0} {
  149.             .xfFontBox.fonts.fonts delete 0 end
  150.           }
  151.           if {\[catch \"open $xfFontBoxTmpFileFont r\" fontInFile\]} {
  152.             if {\"\[info commands XFAlertBox\]\" != \"\"} {
  153.               XFAlertBox \"\$fontInFile\"
  154.             } {
  155.               puts stderr \"\$fontInFile\"
  156.             }
  157.           } {
  158.             set fontReadList \[read \$fontInFile\]
  159.             close \$fontInFile
  160.             foreach fontLine \[split \$fontReadList \"\\n\"\] {
  161.               if {\"\[string trim \$fontLine\]\" != \"\"} {
  162.                 .xfFontBox.fonts.fonts insert end \$fontLine
  163.               }
  164.             }
  165.           }
  166.         }"
  167.     catch ".xfFontBox.frame1.rescan config $tmpButtonOpt"
  168.  
  169.     button .xfFontBox.frame1.cancel \
  170.       -text "Cancel"
  171.     catch ".xfFontBox.frame1.cancel config $tmpButtonOpt"
  172.  
  173.     if {[info exists xfFontBox($xfFontBox(resource)-demo)]} {
  174.       label .xfFontBox.demo \
  175.         -relief raised \
  176.         -text $xfFontBox($xfFontBox(resource)-demo)
  177.     } {
  178.       label .xfFontBox.demo \
  179.         -relief raised \
  180.         -text "This text shows the results :-)"
  181.     }
  182.     catch ".xfFontBox.demo config $tmpMessageOpt"
  183.  
  184.     frame .xfFontBox.current \
  185.       -borderwidth 0 \
  186.       -relief raised
  187.     catch ".xfFontBox.current config $tmpFrameOpt"
  188.  
  189.     label .xfFontBox.current.labelcurrent \
  190.       -relief raised
  191.     catch ".xfFontBox.current.labelcurrent config $tmpMessageOpt"
  192.  
  193.     entry .xfFontBox.current.current \
  194.       -relief raised
  195.     catch ".xfFontBox.current.current config $tmpMessageOpt"
  196.  
  197.     frame .xfFontBox.fonts \
  198.       -borderwidth 0 \
  199.       -relief raised
  200.     catch ".xfFontBox.fonts config $tmpFrameOpt"
  201.  
  202.     scrollbar .xfFontBox.fonts.vscroll \
  203.       -relief raised \
  204.       -command ".xfFontBox.fonts.fonts yview"
  205.     catch ".xfFontBox.fonts.vscroll config $tmpScrollOpt"
  206.  
  207.     scrollbar .xfFontBox.fonts.hscroll \
  208.       -orient horiz \
  209.       -relief raised \
  210.       -command ".xfFontBox.fonts.fonts xview"
  211.     catch ".xfFontBox.fonts.hscroll config $tmpScrollOpt"
  212.  
  213.     listbox .xfFontBox.fonts.fonts \
  214.       -exportselection false \
  215.       -relief raised \
  216.       -xscrollcommand ".xfFontBox.fonts.hscroll set" \
  217.       -yscrollcommand ".xfFontBox.fonts.vscroll set"
  218.     catch ".xfFontBox.fonts.fonts config $tmpMessageOpt"
  219.  
  220.     # family menu
  221.     menubutton .xfFontBox.frame2.family \
  222.       -text "Family" \
  223.       -menu ".xfFontBox.frame2.family.m"
  224.     catch ".xfFontBox.frame2.family config $tmpButtonOpt"
  225.  
  226.     menu .xfFontBox.frame2.family.m
  227.     catch ".xfFontBox.frame2.family.m config $tmpButtonOpt"
  228.  
  229.     .xfFontBox.frame2.family.m add radiobutton \
  230.       -label "*" \
  231.       -value "*" \
  232.       -variable xfFontBox(fontFamily) \
  233.       -command "XFFontBoxComposeFont"
  234.     .xfFontBox.frame2.family.m add radiobutton \
  235.       -label "charter" \
  236.       -value "charter" \
  237.       -variable xfFontBox(fontFamily) \
  238.       -command "XFFontBoxComposeFont"
  239.     .xfFontBox.frame2.family.m add radiobutton \
  240.       -label "courier" \
  241.       -value "courier" \
  242.       -variable xfFontBox(fontFamily) \
  243.       -command "XFFontBoxComposeFont"
  244.     .xfFontBox.frame2.family.m add radiobutton \
  245.       -label "fixed" \
  246.       -value "fixed" \
  247.       -variable xfFontBox(fontFamily) \
  248.       -command "XFFontBoxComposeFont"
  249.     .xfFontBox.frame2.family.m add radiobutton \
  250.       -label "helvetica" \
  251.       -value "helvetica" \
  252.       -variable xfFontBox(fontFamily) \
  253.       -command "XFFontBoxComposeFont"
  254.     .xfFontBox.frame2.family.m add radiobutton \
  255.       -label "jis" \
  256.       -value "jis" \
  257.       -variable xfFontBox(fontFamily) \
  258.       -command "XFFontBoxComposeFont"
  259.     .xfFontBox.frame2.family.m add radiobutton \
  260.       -label "lucida" \
  261.       -value "lucida" \
  262.       -variable xfFontBox(fontFamily) \
  263.       -command "XFFontBoxComposeFont"
  264.     .xfFontBox.frame2.family.m add radiobutton \
  265.       -label "terminal" \
  266.       -value "terminal" \
  267.       -variable xfFontBox(fontFamily) \
  268.       -command "XFFontBoxComposeFont"
  269.     .xfFontBox.frame2.family.m add radiobutton \
  270.       -label "times" \
  271.       -value "times" \
  272.       -variable xfFontBox(fontFamily) \
  273.       -command "XFFontBoxComposeFont"
  274.  
  275.     # weight menu
  276.     menubutton .xfFontBox.frame2.weight \
  277.       -text "Weight" \
  278.       -menu ".xfFontBox.frame2.weight.m"
  279.     catch ".xfFontBox.frame2.weight config $tmpButtonOpt"
  280.  
  281.     menu .xfFontBox.frame2.weight.m
  282.     catch ".xfFontBox.frame2.weight.m config $tmpButtonOpt"
  283.  
  284.     .xfFontBox.frame2.weight.m add radiobutton \
  285.       -label "*" \
  286.       -value "*" \
  287.       -variable xfFontBox(fontWeight) \
  288.       -command "XFFontBoxComposeFont"
  289.     .xfFontBox.frame2.weight.m add radiobutton \
  290.       -label "bold" \
  291.       -value "bold" \
  292.       -variable xfFontBox(fontWeight) \
  293.       -command "XFFontBoxComposeFont"
  294.     .xfFontBox.frame2.weight.m add radiobutton \
  295.       -label "demibold" \
  296.       -value "demibold" \
  297.       -variable xfFontBox(fontWeight) \
  298.       -command "XFFontBoxComposeFont"
  299.     .xfFontBox.frame2.weight.m add radiobutton \
  300.       -label "medium" \
  301.       -value "medium" \
  302.       -variable xfFontBox(fontWeight) \
  303.       -command "XFFontBoxComposeFont"
  304.  
  305.     # Slant menu
  306.     menubutton .xfFontBox.frame2.slant \
  307.       -text "Slant" \
  308.       -menu ".xfFontBox.frame2.slant.m"
  309.     catch ".xfFontBox.frame2.slant config $tmpButtonOpt"
  310.  
  311.     menu .xfFontBox.frame2.slant.m
  312.     catch ".xfFontBox.frame2.slant.m config $tmpButtonOpt"
  313.  
  314.     .xfFontBox.frame2.slant.m add radiobutton \
  315.       -label "*" \
  316.       -value "*" \
  317.       -variable xfFontBox(fontSlant) \
  318.       -command "XFFontBoxComposeFont"
  319.     .xfFontBox.frame2.slant.m add radiobutton \
  320.       -label "i" \
  321.       -value "i" \
  322.       -variable xfFontBox(fontSlant) \
  323.       -command "XFFontBoxComposeFont"
  324.     .xfFontBox.frame2.slant.m add radiobutton \
  325.       -label "o" \
  326.       -value "o" \
  327.       -variable xfFontBox(fontSlant) \
  328.       -command "XFFontBoxComposeFont"
  329.     .xfFontBox.frame2.slant.m add radiobutton \
  330.       -label "r" \
  331.       -value "r" \
  332.       -variable xfFontBox(fontSlant) \
  333.       -command "XFFontBoxComposeFont"
  334.  
  335.     # Set width menu
  336.     menubutton .xfFontBox.frame2.swidth \
  337.       -text "Set width" \
  338.       -menu ".xfFontBox.frame2.swidth.m"
  339.     catch ".xfFontBox.frame2.swidth config $tmpButtonOpt"
  340.  
  341.     menu .xfFontBox.frame2.swidth.m
  342.     catch ".xfFontBox.frame2.swidth.m config $tmpButtonOpt"
  343.  
  344.     .xfFontBox.frame2.swidth.m add radiobutton \
  345.       -label "*" \
  346.       -value "*" \
  347.       -variable xfFontBox(fontSWidth) \
  348.       -command "XFFontBoxComposeFont"
  349.     .xfFontBox.frame2.swidth.m add radiobutton \
  350.       -label "normal" \
  351.       -value "normal" \
  352.       -variable xfFontBox(fontSWidth) \
  353.       -command "XFFontBoxComposeFont"
  354.     .xfFontBox.frame2.swidth.m add radiobutton \
  355.       -label "semicondensed" \
  356.       -value "semicondensed" \
  357.       -variable xfFontBox(fontSWidth) \
  358.       -command "XFFontBoxComposeFont"
  359.  
  360.     # pixels menu
  361.     menubutton .xfFontBox.frame2.pixels \
  362.       -text "Pixels" \
  363.       -menu ".xfFontBox.frame2.pixels.m"
  364.     catch ".xfFontBox.frame2.pixels config $tmpButtonOpt"
  365.  
  366.     menu .xfFontBox.frame2.pixels.m
  367.     catch ".xfFontBox.frame2.pixels.m config $tmpButtonOpt"
  368.  
  369.     .xfFontBox.frame2.pixels.m add radiobutton \
  370.       -label "*" \
  371.       -value "*" \
  372.       -variable xfFontBox(fontPixels) \
  373.       -command "XFFontBoxComposeFont"
  374.     .xfFontBox.frame2.pixels.m add radiobutton \
  375.       -label "6 pixels" \
  376.       -value "6" \
  377.       -variable xfFontBox(fontPixels) \
  378.       -command "XFFontBoxComposeFont"
  379.     .xfFontBox.frame2.pixels.m add radiobutton \
  380.       -label "8 pixels" \
  381.       -value "8" \
  382.       -variable xfFontBox(fontPixels) \
  383.       -command "XFFontBoxComposeFont"
  384.     .xfFontBox.frame2.pixels.m add radiobutton \
  385.       -label "10 pixels" \
  386.       -value "10" \
  387.       -variable xfFontBox(fontPixels) \
  388.       -command "XFFontBoxComposeFont"
  389.     .xfFontBox.frame2.pixels.m add radiobutton \
  390.       -label "12 pixels" \
  391.       -value "12" \
  392.       -variable xfFontBox(fontPixels) \
  393.       -command "XFFontBoxComposeFont"
  394.     .xfFontBox.frame2.pixels.m add radiobutton \
  395.       -label "13 pixels" \
  396.       -value "13" \
  397.       -variable xfFontBox(fontPixels) \
  398.       -command "XFFontBoxComposeFont"
  399.     .xfFontBox.frame2.pixels.m add radiobutton \
  400.       -label "14 pixels" \
  401.       -value "14" \
  402.       -variable xfFontBox(fontPixels) \
  403.       -command "XFFontBoxComposeFont"
  404.     .xfFontBox.frame2.pixels.m add radiobutton \
  405.       -label "16 pixels" \
  406.       -value "16" \
  407.       -variable xfFontBox(fontPixels) \
  408.       -command "XFFontBoxComposeFont"
  409.     .xfFontBox.frame2.pixels.m add radiobutton \
  410.       -label "18 pixels" \
  411.       -value "18" \
  412.       -variable xfFontBox(fontPixels) \
  413.       -command "XFFontBoxComposeFont"
  414.     .xfFontBox.frame2.pixels.m add radiobutton \
  415.       -label "24 pixels" \
  416.       -value "24" \
  417.       -variable xfFontBox(fontPixels) \
  418.       -command "XFFontBoxComposeFont"
  419.     .xfFontBox.frame2.pixels.m add radiobutton \
  420.       -label "28 pixels" \
  421.       -value "28" \
  422.       -variable xfFontBox(fontPixels) \
  423.       -command "XFFontBoxComposeFont"
  424.     .xfFontBox.frame2.pixels.m add radiobutton \
  425.       -label "30 pixels" \
  426.       -value "30" \
  427.       -variable xfFontBox(fontPixels) \
  428.       -command "XFFontBoxComposeFont"
  429.  
  430.     # read font file
  431.     if {"$xfFontBoxFileFont" != ""} {
  432.       if {[catch "open $xfFontBoxFileFont r" fontInFile]} {
  433.         set xfFontBoxFileFont ""
  434.         if {"[info commands XFAlertBox]" != ""} {
  435.           XFAlertBox "$fontInFile"
  436.         } {
  437.           puts stderr "$fontInFile"
  438.         }
  439.       } {
  440.         set fontReadList [read $fontInFile]
  441.         close $fontInFile
  442.         foreach fontLine [split $fontReadList "\n"] {
  443.           if {"[string trim $fontLine]" != ""} {
  444.             .xfFontBox.fonts.fonts insert end $fontLine
  445.           }
  446.         }
  447.       }
  448.     }
  449.   } {
  450.     if {"[winfo class $xfFontBox(oldWidget)]" == "Text"} {
  451.       catch "$xfFontBox(oldWidget) delete 1.0 end"
  452.       catch "$xfFontBox(oldWidget) insert 1.0 [.xfFontBox.current.current get]"
  453.     } {
  454.       if {"[winfo class $xfFontBox(oldWidget)]" == "Entry"} {
  455.         catch "$xfFontBox(oldWidget) delete 0 end"
  456.         catch "$xfFontBox(oldWidget) insert 0 [.xfFontBox.current.current get]"
  457.       }
  458.     }
  459.  
  460.     set xfFontBox(oldWidget) $xfFontBoxEntryW
  461.   }
  462.  
  463.   .xfFontBox.frame1.ok config \
  464.     -command "
  465.       global xfFontBox
  466.       set xfFontBox(fontName) \[.xfFontBox.current.current get\]
  467.       if {\"$xfFontBoxEntryW\" != \"\"} {
  468.         if {\"\[winfo class $xfFontBoxEntryW\]\" == \"Text\"} {
  469.           catch \"$xfFontBoxEntryW delete 1.0 end\"
  470.           catch \"$xfFontBoxEntryW insert 1.0 \\\"\$xfFontBox(fontName)\\\"\"
  471.         } {
  472.           if {\"\[winfo class $xfFontBoxEntryW\]\" == \"Entry\"} {
  473.             catch \"$xfFontBoxEntryW delete 0 end\"
  474.             catch \"$xfFontBoxEntryW insert 0 \\\"\$xfFontBox(fontName)\\\"\"
  475.           }
  476.         }
  477.       }
  478.       if {\"\[info commands XFDestroy\]\" != \"\"} {
  479.         catch {XFDestroy .xfFontBox}
  480.       } {
  481.         catch {destroy .xfFontBox}
  482.       }"
  483.  
  484.   .xfFontBox.frame1.cancel config \
  485.     -command "
  486.       global xfFontBox
  487.       set xfFontBox(fontName) {}
  488.       if {\"$xfFontBoxTargetW\" != \"\"} {
  489.         catch \"$xfFontBoxTargetW config -$xfFontBox(resource) $xfFontBoxSavedFont\"
  490.       }
  491.       if {\"\[info commands XFDestroy\]\" != \"\"} {
  492.         catch {XFDestroy .xfFontBox}
  493.       } {
  494.         catch {destroy .xfFontBox}
  495.       }"
  496.  
  497.   .xfFontBox.current.labelcurrent config \
  498.     -text "$xfFontBoxResource:"
  499.  
  500.   # bindings
  501.   bind .xfFontBox.current.current <Return> "
  502.     XFFontBoxSetFont \"$xfFontBoxTargetW\""
  503.  
  504.   bind .xfFontBox.fonts.fonts <Double-1> "
  505.     XFFontBoxSelectFont %W \"$xfFontBoxTargetW\" %y
  506.     global xfFontBox
  507.     set xfFontBox(fontName) \[.xfFontBox.current.current get\]
  508.     if {\"$xfFontBoxEntryW\" != \"\"} {
  509.       if {\"\[winfo class $xfFontBoxEntryW\]\" == \"Text\"} {
  510.         catch \"$xfFontBoxEntryW delete 1.0 end\"
  511.         catch \"$xfFontBoxEntryW insert 1.0 \\\"\$xfFontBox(fontName)\\\"\"
  512.       } {
  513.         if {\"\[winfo class $xfFontBoxEntryW\]\" == \"Entry\"} {
  514.           catch \"$xfFontBoxEntryW delete 0 end\"
  515.           catch \"$xfFontBoxEntryW insert 0 \\\"\$xfFontBox(fontName)\\\"\"
  516.         }
  517.       }
  518.     }
  519.     if {\"\[info commands XFDestroy\]\" != \"\"} {
  520.       catch {XFDestroy .xfFontBox}
  521.     } {
  522.       catch {destroy .xfFontBox}
  523.     }"
  524.   bind .xfFontBox.fonts.fonts <ButtonPress-1> "
  525.     XFFontBoxSelectFont %W \"$xfFontBoxTargetW\" %y"
  526.   bind .xfFontBox.fonts.fonts <Button1-Motion> "
  527.     XFFontBoxSelectFont %W \"$xfFontBoxTargetW\" %y"
  528.   bind .xfFontBox.fonts.fonts <Shift-ButtonPress-1> "
  529.     XFFontBoxSelectFont %W \"$xfFontBoxTargetW\" %y"
  530.   bind .xfFontBox.fonts.fonts <Shift-Button1-Motion> "
  531.     XFFontBoxSelectFont %W \"$xfFontBoxTargetW\" %y"
  532.  
  533.   # set up current value
  534.   .xfFontBox.current.current delete 0 end
  535.   if {"$xfFontBoxEntryW" != ""} {
  536.     if {"[winfo class $xfFontBoxEntryW]" == "Text"} {
  537.       .xfFontBox.current.current insert 0 [$xfFontBoxEntryW get 1.0 end]
  538.     } {
  539.       if {"[winfo class $xfFontBoxEntryW]" == "Entry"} {
  540.         .xfFontBox.current.current insert 0 [$xfFontBoxEntryW get]
  541.       }
  542.     }
  543.   }
  544.  
  545.   # packing
  546.   pack append .xfFontBox.frame1 \
  547.               .xfFontBox.frame1.ok {left fill expand} \
  548.               .xfFontBox.frame1.rescan {left fill expand} \
  549.               .xfFontBox.frame1.cancel {left fill expand}
  550.   pack append .xfFontBox.frame2 \
  551.               .xfFontBox.frame2.family {left} \
  552.               .xfFontBox.frame2.weight {left} \
  553.               .xfFontBox.frame2.slant {left} \
  554.               .xfFontBox.frame2.swidth {left} \
  555.               .xfFontBox.frame2.pixels {left}
  556.   pack append .xfFontBox.current \
  557.               .xfFontBox.current.labelcurrent {left} \
  558.               .xfFontBox.current.current {left fill expand}
  559.   pack append .xfFontBox.fonts \
  560.               .xfFontBox.fonts.vscroll "$xfFontBox(scrollSide) filly" \
  561.               .xfFontBox.fonts.hscroll {bottom fillx} \
  562.               .xfFontBox.fonts.fonts {left fill expand}
  563.  
  564.   if {"$xfFontBoxFileFont" != ""} {
  565.     pack append .xfFontBox \
  566.                 .xfFontBox.frame1 {bottom fillx} \
  567.                 .xfFontBox.current {bottom fillx} \
  568.                 .xfFontBox.demo {bottom fillx} \
  569.                 .xfFontBox.frame2 {top fill} \
  570.                 .xfFontBox.fonts {left expand fill}
  571.   } {
  572.     wm geometry .xfFontBox 400x90
  573.     pack append .xfFontBox \
  574.                 .xfFontBox.frame1 {bottom fillx} \
  575.                 .xfFontBox.current {bottom fillx} \
  576.                 .xfFontBox.frame2 {top fill} \
  577.                 .xfFontBox.demo {bottom fill expand}
  578.   }
  579.   catch "wm deiconify .xfFontBox"
  580.  
  581.   if {"$xfFontBoxEntryW" == ""} {
  582.     # wait for the box to be destroyed
  583.     update idletask
  584.     grab .xfFontBox
  585.     tkwait window .xfFontBox
  586.  
  587.     return $xfFontBox(fontName)
  588.   }
  589. }
  590.  
  591. ##########
  592. # Procedure: XFFontBoxComposeFont
  593. # Description: set the font
  594. # Arguments: none
  595. # Returns: none
  596. # Sideeffects: none
  597. ##########
  598. proc XFFontBoxComposeFont {} {# xf ignore me 6
  599.   global xfFontBox
  600.   
  601.   if {"$xfFontBox(fontFamily)" != "*"} {
  602.     append fontNewFont * $xfFontBox(fontFamily)
  603.   } {
  604.     append fontNewFont *
  605.   }
  606.   if {"$xfFontBox(fontWeight)" != "*"} {
  607.     append fontNewFont - $xfFontBox(fontWeight)
  608.   } {
  609.     append fontNewFont - *
  610.   }
  611.   if {"$xfFontBox(fontSlant)" != "*"} {
  612.     append fontNewFont - $xfFontBox(fontSlant)
  613.   } {
  614.     append fontNewFont - *
  615.   }
  616.   if {"$xfFontBox(fontSWidth)" != "*"} {
  617.     append fontNewFont - $xfFontBox(fontSWidth)
  618.   } {
  619.     append fontNewFont - *
  620.   }
  621.   append fontNewFont - *
  622.   if {"$xfFontBox(fontPixels)" != "*"} {
  623.     append fontNewFont - $xfFontBox(fontPixels)
  624.   } {
  625.     append fontNewFont -
  626.   }
  627.   append fontNewFont *
  628.  
  629.   .xfFontBox.current.current delete 0 end
  630.   .xfFontBox.current.current insert 0 $fontNewFont
  631.   catch ".xfFontBox.demo config \
  632.     -$xfFontBox(resource) $fontNewFont"
  633. }
  634.  
  635. ##########
  636. # Procedure: XFFontBoxSelectFont
  637. # Description: select font for font composing
  638. # Arguments: xfFontBoxW - the widget
  639. #            xfFontBoxTargetW - the widget we configure
  640. #            xfFontBoxY - the y position in the listbox
  641. # Returns: none
  642. # Sideeffects: none
  643. ##########
  644. proc XFFontBoxSelectFont {xfFontBoxW xfFontBoxTargetW xfFontBoxY} {# xf ignore me 6
  645.  
  646.   set xfFontBoxNearest [$xfFontBoxW nearest $xfFontBoxY]
  647.   if {$xfFontBoxNearest >= 0} {
  648.     $xfFontBoxW select from $xfFontBoxNearest
  649.     $xfFontBoxW select to $xfFontBoxNearest
  650.     .xfFontBox.current.current delete 0 end
  651.     .xfFontBox.current.current insert 0 [$xfFontBoxW get $xfFontBoxNearest]
  652.     XFFontBoxSetFont "$xfFontBoxTargetW"
  653.   }
  654. }
  655.  
  656. ##########
  657. # Procedure: XFFontBoxSetFont
  658. # Description: set font for the widget
  659. # Arguments: xfFontBoxTargetW - the widget we configure
  660. # Returns: none
  661. # Sideeffects: none
  662. ##########
  663. proc XFFontBoxSetFont {xfFontBoxTargetW} {# xf ignore me 6
  664.   global xfFontBox
  665.  
  666.   if {"[.xfFontBox.current.current get]" != ""} {
  667.     catch ".xfFontBox.demo config -$xfFontBox(resource) \
  668.       [.xfFontBox.current.current get]"
  669.     if {"$xfFontBoxTargetW" != ""} {
  670.       catch "$xfFontBoxTargetW config -$xfFontBox(resource) \
  671.         [.xfFontBox.current.current get]"
  672.     }
  673.   }
  674. }
  675.  
  676. # eof
  677.  
  678.